package com.me.ui;

import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.me.constant.Constant;
import com.me.enums.ScreenEnum;
import com.me.helper.PreferencesData;
import com.me.memorytest.MainMemoryTest;

public class HeaderGame extends Group{
	public static Image img_bgHide = new Image(Constant.atlas.findRegion("datagame/bg_popup"));
	public static Label lb_Click = new Label("Clicked: " + Constant.iCountClicked+" ", Constant.skin, "label30Bold_click");
	public HeaderGame(String title, float w, float h, final int iScreen){
		Image img_bgTop, img_bgBottom, img_background;
		Label lb_title;
		ImageButton img_back;
		
		img_bgTop = new Image(Constant.atlas.findRegion("datagame/menu-bottom-thanh-ngang"));
		img_bgTop.setBounds(0, h-90, w, 90);
		
		img_bgBottom = new Image(Constant.atlas.findRegion("datagame/menu-bottom-thanh-ngang"));
		img_bgBottom.setBounds(0, 0, w, 90);
		
		lb_title = new Label(title, Constant.skin,"labelMenu");
		lb_title.setX(w/2 - lb_title.getWidth()/2);
		lb_title.setY(h - img_bgTop.getHeight() + (img_bgTop.getHeight() - lb_title.getHeight())/2);		
		
		lb_Click.setBounds(w-200, h-90, 160, 90);
		
		TextureRegionDrawable bup = new TextureRegionDrawable(Constant.atlas.findRegion("datagame/Back_up"));
		TextureRegionDrawable bdown = new TextureRegionDrawable(Constant.atlas.findRegion("datagame/Back_down"));
		img_back = new ImageButton(bup, bdown);
		img_back.setX(20);

		img_back.setY(h- img_bgTop.getHeight() + (img_bgTop.getHeight() - img_back.getHeight())/2);
		img_back.addListener(new ClickListener(){
			@Override
			public void touchUp(InputEvent event, float x, float y,
					int pointer, int button) {
				super.touchUp(event, x, y, pointer, button);
				Constant.iCountClicked = PreferencesData.getCountClicked();
				MainMemoryTest.getScreenManager().createScreen(ScreenEnum.MENU_SCREEN);
				MainMemoryTest.getScreenManager().getScreen().show();
			}
		});
		
		img_background = new Image(Constant.atlas.findRegion("datagame/backGround"));
		
		this.addActor(img_background);
		this.addActor(img_bgTop);
		this.addActor(img_bgBottom);
		this.addActor(lb_title);
		this.addActor(img_back);
		this.addActor(lb_Click);
		
	}
}
